<form id="questions-index-form" action="__URL__/index" method="post">

    <input type="hidden" name="pagenum" id="pagenum_hidden">
    <input type="hidden" name="count" value="{$recordcount}">

    <div class="table-tools">

        <div class="form-group">
            <input type="text" name="username" value="{$username}" placeholder="请输入用户名">
            <input type="text" name="nickname" value="{$nickname}" placeholder="请输入用户昵称">
            <button type="submit">搜索</button>
        </div>

        <a href="{:U('SchoolAdmin/addUI')}" class="btn btn-info" title="添加新的学校管理员"><i class="fa fa-copy"></i> 添 加 </a>

        <p>管理员列表</p>
    </div>

    <table id="questions-table" class="table table-striped table-hover table-condensed datatable">
        <thead>
            <tr>
                <th width="50px"> </th>
                <th>ID</th>
                <th>管理员名称</th>
                <th width="150px">操作</th>

            </tr>
        </thead>
        <tbody>
        	<volist name="list" id="vo">
                <tr id="tr-{$vo.adminid}">
        			<td width="50px"><input name='id[]' type="checkbox" value="{$vo.id}" /></td>
        			<td class="question-name">{$vo.id}</td>
                    <td class="question-name">{$vo.username}</td>
        			<td width="150px">
                        <a href="__APP__/Admin/Admin/authorizeUI/{$vo.id}" class="btn btn-default btn-rounded btn-condensed btn-sm" title="授权"><span class="glyphicon glyphicon-ok"></span>
                        </a>
        			</td>

        		</tr>
        	</volist>
        </tbody>
    </table>

    <nav style="float:right">
        <spen class="total">共 {$recordcount}条记录</spen>
        <div class="fr">
            <ul class="pagination">
                <eq name="page['pagenum']" value="1">
                    <li class="disabled">
                        <else/>
                    <li>
                </eq>
                <a href="#" onclick="gotoPage('1')">«</a></li>
                <foreach name="page.pagenums" item="vo">
                    <eq name="page['pagenum']" value="$vo">
                        <li class="active"><a href="#">{$vo}</a></li>
                        <else/>
                        <li><a href="#" onclick="gotoPage('{$vo}')">{$vo}</a></li>
                    </eq>
                </foreach>
                <eq name="page['pagenum']" value="$page.endPage">
                    <li class="disabled">
                        <else/>
                    <li>
                </eq>
                <a href="#" onclick="gotoPage('{$page.totalpage}')">»</a></li>
            </ul>
        </div>
    </nav>

    <!-- Modal -->
    <div class="modal fade" id="my-alert" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                    <h4 class="modal-title" id="myModalLabel">提示</h4>
                </div>
                <div class="modal-body" id="hint_content">
                </div>
                <div class="modal-footer">
                    <button type="button" id="close_btn" class="btn btn-default" data-dismiss="modal">关闭</button>
                    <button type="button" class="btn btn-primary" id="save-change" data-dismiss="modal">Save changes</button>
                </div>
            </div>
        </div>
    </div>
</form>
<script>
    function gotoPage(pagenum) {
        //提交form
        $('#pagenum_hidden').val(pagenum);
        $('form').submit();
    }

    function deleteData(id) {
        console.info(id);
        $("#hint_content").empty().append('是否删除');
        $("#my-alert").modal('show');
        $('#close_btn').unbind('click');
        $('#save-change').on('click', function(){

            $.ajax({
                type: "GET",
                url: "__URL__/delete",
                data: {id: id},
                dataType: "json",
                success: function (data) {
                    console.info(data);
                    $("#hint_content1").empty().append(data.message);
                    $("#my-alert1").modal('show');
                    if (data.check) {
                        $('#' + 'tr-' + id).remove();
                        var count =$('[name=count]').val()-1;
                        $('.total').empty().append('共 '+count+' 条记录');
                    }
                },
                error: function (data) {
                    $("#hint_content1").empty().append('服务器忙');
                    $("#my-alert1").modal('show');
                }
            });


        })
    }
    </script>